home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_014 / termcap / tgetflag.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  87 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *            Copyright (c) 1982, Fred Fish            *
  4.  *                All Rights Reserved                *
  5.  *                                    *
  6.  *    This software and/or documentation is released for public    *
  7.  *    distribution for personal, non-commercial use only.        *
  8.  *    Limited rights to use, modify, and redistribute are hereby    *
  9.  *    granted for non-commercial purposes, provided that all        *
  10.  *    copyright notices remain intact and all changes are clearly    *
  11.  *    documented.  The author makes no warranty of any kind with    *
  12.  *    respect to this product and explicitly disclaims any implied    *
  13.  *    warranties of merchantability or fitness for any particular    *
  14.  *    purpose.                            *
  15.  *                                    *
  16.  ************************************************************************
  17.  */
  18.  
  19.  
  20. /*
  21.  *  LIBRARY FUNCTION
  22.  *
  23.  *    tgetflag   extract boolean termcap capability
  24.  *
  25.  *  KEY WORDS
  26.  *
  27.  *    termcap
  28.  *
  29.  *  SYNOPSIS
  30.  *
  31.  *    tgetflag(id)
  32.  *    char *id;
  33.  *
  34.  *  DESCRIPTION
  35.  *
  36.  *    Returns TRUE if specified id is present in terminal
  37.  *    entry, FALSE otherwise.
  38.  *
  39.  */
  40.  
  41. #include <stdio.h>
  42.  
  43. #define TRUE 1
  44. #define FALSE 0
  45.  
  46. extern char *_tcpbuf;        /* Termcap entry buffer pointer */
  47.  
  48. /*
  49.  *  PSEUDO CODE
  50.  *
  51.  *    Begin tgetflag
  52.  *        Initialize pointer to the termcap entry buffer.
  53.  *        While there is a field to process
  54.  *        Skip over the field separator character.
  55.  *        If this is the entry we want then
  56.  *            If entry is identifier only then
  57.  *            Return TRUE
  58.  *            Else
  59.  *            Return FALSE
  60.  *            End if
  61.  *        End if
  62.  *        End while
  63.  *        Return FALSE as default.
  64.  *    End tgetflag
  65.  *
  66.  */
  67.  
  68. tgetflag(id)
  69. char *id;
  70. {
  71.     char *bp;
  72.     extern char *index();
  73.  
  74.     bp = _tcpbuf;
  75.     while ((bp = index(bp,':')) != NULL) {
  76.     bp++;
  77.     if (*bp++ == id[0] && *bp != NULL && *bp++ == id[1]) {
  78.         if (*bp == NULL || *bp++ == ':') {
  79.         return(TRUE);
  80.         } else {
  81.         return(FALSE);
  82.         }
  83.     }
  84.     }
  85.     return(FALSE);
  86. }
  87.